/* 
 * File:   Peer.h
 * Author: robbiediaz
 *
 * Created on February 2, 2009, 9:57 AM
 */

#ifndef _PEER_H
#define	_PEER_H

#ifdef __APPLE__
#ifndef unix
#define unix 1
#endif
#endif

#ifdef linux
#ifndef unix
#define unix 1
#endif
#endif

#include <string>
#include <sys/socket.h>

class Peer {
public:

    virtual ~Peer() {
        close(sockfd);
    }

    std::string getIpAddr() {
        return ipAddr;
    }

    int getPort() {
        return port;
    }

    void setIpAddr(std::string ip) {
        ipAddr = ip;
    }

    void setPort(int p) {
        port = p;
    }

#ifdef unix

    int getSockFd() {
        return sockfd;
    }

    void setSockFd(int sock) {
        sockfd = sock;
    }
#endif

#ifdef WIN32

    SOCKET getSockFd() {
        return sockfd;
    }

    void setSockFd(SOCKET sock) {
        sockfd = sock;
    }
#endif
private:
    std::string ipAddr;
    int port;

#ifdef unix
    int sockfd;
#endif
#ifdef WIN32
    SOCKET sockfd;
#endif
};

#endif	/* _PEER_H */

